package edu.utdallas_elearn_calendar.utdallas_elearn_calendar_app;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;


import edu.utdallas_elearn_calendar.utdallas_elearn_calendar_app.UnivClassEvent;
import edu.utdallas_elearn_calendar.utdallas_elearn_calendar_db.CalDbAdapter;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
//import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
//import android.widget.Toast;

public class CalendarView extends Activity implements OnClickListener
{
	private static final String tag = "CalendarViewActivity";

	private CalDbAdapter dbHelper;
	private ArrayList<UnivClassEvent> listEvents;
	private HashMap<String,ArrayList<UnivClassEvent>> eventsByDate;
	private static final int DIALOG_EVENTS = 0;
	
//	private ImageView calendarToJournalButton;
	private Button selectedDayMonthYearButton;
	private Button currentMonth;
	private ImageView prevMonth;
	private ImageView nextMonth;
	private GridView calendarView;
	private GridCellAdapter adapter;
	private Calendar _calendar;
	private int month, year;
	private final DateFormat dateFormatter = new DateFormat();
	private static final String dateTemplate = "MMMM yyyy";
	private static final String fullDateTemplate = "MMMM dd yyyy";

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_calendar_view);
        
        dbHelper = new CalDbAdapter(this);
		dbHelper.open();
		
        listEvents = GetEvents();
        eventsByDate = new HashMap<String,ArrayList<UnivClassEvent>>();
        Date d;
        for(UnivClassEvent e : listEvents)
        {
        	d = e.getDueDate();
        	ArrayList<UnivClassEvent> eventsList;
        	if((eventsList = eventsByDate.get(DateFormat.format(fullDateTemplate, d).toString())) == null)
        	{
        		eventsList = new ArrayList<UnivClassEvent>();
        		eventsList.add(e);
        		eventsByDate.put(DateFormat.format(fullDateTemplate, d).toString(), eventsList);
        	}
        	else
        	{
        		eventsList.add(e);
        		eventsByDate.remove(DateFormat.format(fullDateTemplate, d).toString());
        		eventsByDate.put(DateFormat.format(fullDateTemplate, d).toString(), eventsList);
        	}
        	Log.d(tag,"Added event "+e.Name+" for date "+dateFormatter.format(fullDateTemplate, d)+ "to date map.");
       	
        }
        
        _calendar = Calendar.getInstance(Locale.getDefault());
		month = _calendar.get(Calendar.MONTH) + 1;
		year = _calendar.get(Calendar.YEAR);
		Log.d(tag, "Calendar Instance:= " + "Month: " + month + " " + "Year: " + year);
		
		selectedDayMonthYearButton = (Button) this.findViewById(R.id.selectedDayMonthYear);
		if(selectedDayMonthYearButton == null)
			Log.d(tag,"Button not found.");
		else
		selectedDayMonthYearButton.setText("Selected: ");

		prevMonth = (ImageView) this.findViewById(R.id.prevMonth);
		prevMonth.setOnClickListener(this);

		currentMonth = (Button) this.findViewById(R.id.currentMonth);
		currentMonth.setText(dateFormatter.format(dateTemplate, _calendar.getTime()));

		nextMonth = (ImageView) this.findViewById(R.id.nextMonth);
		nextMonth.setOnClickListener(this);

		calendarView = (GridView) this.findViewById(R.id.calendar);

		// Initialised
		adapter = new GridCellAdapter(getApplicationContext(), R.id.calendar_day_gridcell, month, year);
		adapter.notifyDataSetChanged();
		calendarView.setAdapter(adapter);
    }

	public void onPause()
	{
		super.onPause();
		//dbHelper.close();
	}
	
	public void onResume()
	{
		super.onResume();
		//dbHelper.open();
	}
	
	public long getIDByName(String name)
	{
		if (name.contains("*-")) {
			name=name.substring(0,name.indexOf("*"))+name.substring(name.indexOf("*")+1,name.length());
		}
		
		Log.d("Event Name", name);
		
		listEvents = GetEvents();
		long id = -1;
		
		String n;
		for(UnivClassEvent e : listEvents)
		{
			n = e.EventId + " - " + e.Name;
			if(n.equals(name))
				return e.EventId;
		}
		
		return id;
	}
	
	private DialogInterface.OnClickListener dialogEventClick = new DialogInterface.OnClickListener()
    {		
    	public void onClick(DialogInterface dialog, int i)
    	{
    		try
    		{
    			AlertDialog d = (AlertDialog) dialog;
        		Intent viewEvent = new Intent(d.getContext(), event_edit.class);
        		
        		//String dItem = d.getListView().getAdapter().getItem(i).toString();
        		
        		//long id = Long.parseLong(dItem.substring(0, dItem.indexOf(" ")));
        		
        		long id = getIDByName(d.getListView().getAdapter().getItem(i).toString());
        		
//        		if(id == -1)
//        		{
//        			dbHelper.insertEvent(1, 1, "DEFAULT", "2011-11-28 16:00", 0);
//        			id = getIDByName("DEFAULT");
//        		}
//        		if(id == -1)
//        			throw new Exception("EVENT NOT FOUND");
        			
	    		Log.d("Events", "dialogEventClick: passing id to screen: " + id);
	    		if(id != -1)
	    			viewEvent.putExtra("_id", id);	    		
				startActivity(viewEvent);
				//startActivityForResult(viewEvent, EDIT_EVENT);
    		}
    		catch(Exception e)
    		{
    			Log.e("Events", "dialogEventClick error: " + e.toString());
    		}
    	}
    };
	
	protected Dialog onCreateDialog(int id, Bundle b)
	{
		Dialog dialog;
		Log.d(tag,"onCreateDialog call");
		
		switch(id) {
		case DIALOG_EVENTS:
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setTitle("Select an event to view");

			CharSequence[] items = {"Add a new event"};

			builder.setItems(items, dialogEventClick);

			dialog = builder.create();
			break;
		default:
			dialog = null;
		}
		return dialog;
	}
	
	protected void onPrepareDialog(int id, Dialog dialog, Bundle b)
	{
		
		Log.d(tag,"onPrepare call");
		switch(id) {
		case DIALOG_EVENTS:
			Log.d(tag,"in DATES_EVENTS case");
			
			ListView dropdown = ((AlertDialog)dialog).getListView();
			//dropdown.setBackgroundColor(R.color.BGGray);
			dropdown.setBackgroundResource(R.drawable.calendar_bg_orange);
			ArrayAdapter<CharSequence> newAdapter = new ArrayAdapter<CharSequence>(this,R.layout.list_item);
			
			ArrayList<UnivClassEvent> events = getEventsForDate((Date) b.get("DATE"));
			CharSequence[] items;
			if(events == null)
				items = new CharSequence[] {"Add new event"};
			else
			{
				items = new CharSequence[events.size() + 1];
				items[0] = "Add new event";
				for(int x = 0; x < events.size(); x++)
					items[x + 1] = (CharSequence)(events.get(x).EventId +" - "+ events.get(x).Name);
			}
			
			for(CharSequence c : items)
				newAdapter.add(c);
			
			dropdown.setAdapter(newAdapter);
		
			break;
		default:
			dialog = null;
		}

	}
	
	private ArrayList<UnivClassEvent> getEventsForDate(Date d)
	{
		Log.d(tag,"Getting events for date "+ dateFormatter.format(fullDateTemplate, d) + " from map.");
		String dateString = dateFormatter.format(fullDateTemplate, d).toString();
		//Log.d("getEventsForDate", "date used = " + dateFormatter.format(fullDateTemplate, d));
		return eventsByDate.get(dateString);
	}
	
	/**
	 * 
	 * @param month
	 * @param year
	 */
	private void setGridCellAdapterToDate(int month, int year)
		{
			adapter = new GridCellAdapter(getApplicationContext(), R.id.calendar_day_gridcell, month, year);
			_calendar.set(year, month - 1, _calendar.get(Calendar.DAY_OF_MONTH));
			currentMonth.setText(dateFormatter.format(dateTemplate, _calendar.getTime()));
			adapter.notifyDataSetChanged();
			calendarView.setAdapter(adapter);
		}
	
	public void onClick(View v)
		{
			if (v == prevMonth)
				{
					if (month <= 1)
						{
							month = 12;
							year--;
						}
					else
						{
							month--;
						}
					Log.d(tag, "Setting Prev Month in GridCellAdapter: " + "Month: " + month + " Year: " + year);
					setGridCellAdapterToDate(month, year);
				}
			if (v == nextMonth)
				{
					if (month > 11)
						{
							month = 1;
							year++;
						}
					else
						{
							month++;
						}
					Log.d(tag, "Setting Next Month in GridCellAdapter: " + "Month: " + month + " Year: " + year);
					setGridCellAdapterToDate(month, year);
				}

		}
	
	@Override
	public void onDestroy()
		{
			if (dbHelper != null) {
				dbHelper.close();
			}
			Log.d(tag, "Destroying View ...");
			super.onDestroy();
		}
	
	public ArrayList<UnivClassEvent> GetEvents()
	{
		Log.i("DATABASE", "call to GetEvents");
		ArrayList<UnivClassEvent> listEvents = new ArrayList<UnivClassEvent>();
		
		SimpleDateFormat df = new SimpleDateFormat();
		df.applyPattern(events.FORMAT_DATE_TIME);
		
		try
		{			
			Cursor result = dbHelper.getViewAllMonthEvents(year + "-" + month + "-1");
			startManagingCursor(result);
			
			if(result.getCount() > 0)
			{
				result.moveToFirst();
				do
				{					
					UnivClassEvent Event = new UnivClassEvent();
					Event.EventId = result.getLong(result.getColumnIndexOrThrow(CalDbAdapter.EVENT_ID));
					Event.ClassId = result.getLong(result.getColumnIndexOrThrow(CalDbAdapter.CLASS_ID));
					Event.EventTypeId = result.getLong(result.getColumnIndexOrThrow(CalDbAdapter.EVENT_TYPE_ID));
					Event.EventType = result.getString(result.getColumnIndexOrThrow(CalDbAdapter.EVENT_TYPE));
					Event.Name = result.getString(result.getColumnIndexOrThrow(CalDbAdapter.EVENT_NAME));
	
					String eDueDate = result.getString(result.getColumnIndexOrThrow(CalDbAdapter.EVENT_DUE));
					if(eDueDate != null)
						Event.DueDate = df.parse(eDueDate);					
					
					Event.RecurringType = result.getInt(result.getColumnIndexOrThrow(CalDbAdapter.EVENT_RECURRENCE));
					Event.ReminderId = result.getLong(result.getColumnIndexOrThrow(CalDbAdapter.REMINDER_ID));
					Event.MinutesPrior = result.getLong(result.getColumnIndexOrThrow(CalDbAdapter.REMINDER_MINUTES));
					Event.PriorityId = result.getLong(result.getColumnIndexOrThrow(CalDbAdapter.EVENT_PRIORITY));
					Event.PriorityVal = result.getInt(result.getColumnIndexOrThrow(CalDbAdapter.PRIORITY_VAL));
					Event.Color = result.getString(result.getColumnIndexOrThrow(CalDbAdapter.PRIORITY_COLOR));					
					
					listEvents.add(Event);
				}
				while(result.moveToNext());
			}
			else
			{
				Log.i("DATABASE", "GetEvents: no events found");
			}
			
			result.close();
		}
		catch(Exception e)
		{
			Log.e("DATABASE", "GetEvents error: " + e.toString() + e.getMessage());
		}
		return listEvents;
	}  
	
	private int[] getEventDays(int intMonthDays) {
		
		int[] intEventDays = new int[intMonthDays+1];
		Date dtRec = new Date();
		
		//initialize the array to hold 0s
		for (int i=0; i<intEventDays.length; i++) {
			intEventDays[i] = 0;
		}
		
		Log.i("DATABASE", "call to getEventDays");		
		SimpleDateFormat df = new SimpleDateFormat();
		df.applyPattern(events.FORMAT_DATE_TIME);
		
		try
		{			
			Cursor result = dbHelper.getViewAllMonthEvents(year + "-" + month + "-1");
			startManagingCursor(result);
			
			if(result.getCount() > 0)
			{
				result.moveToFirst();
				do
				{					
					String eDueDate = result.getString(result.getColumnIndexOrThrow(CalDbAdapter.EVENT_DUE));
					if(eDueDate != null)
						dtRec = df.parse(eDueDate);	
					
					intEventDays[dtRec.getDate()] = 1;
				}
				while(result.moveToNext());
			}
			else
			{
				Log.i("DATABASE", "getEventDays: no events found");
			}
			
			result.close();
		}
		catch(Exception e)
		{
			Log.e("DATABASE", "getEventDays error: " + e.toString() + e.getMessage());
		}

		return intEventDays;
	}
	
	
	public class GridCellAdapter extends BaseAdapter implements OnClickListener
	{
		private static final String tag = "GridCellAdapter";
		private final Context _context;

		private final List<String> list;
		private static final int DAY_OFFSET = 1;
		private final String[] weekdays = new String[]{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
		private final String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
		private final int[] daysOfMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		private final int month, year;
		private int daysInMonth, prevMonthDays;
		private int currentDayOfMonth;
		private int currentWeekDay;
		private Button gridcell;
		private TextView num_events_per_day;
		private final HashMap eventsPerMonthMap;
		private final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MMM-yyyy");

		// Days in Current Month
		public GridCellAdapter(Context context, int textViewResourceId, int month, int year)
			{
				super();
				this._context = context;
				this.list = new ArrayList<String>();
				this.month = month;
				this.year = year;

				Log.d(tag, "==> Passed in Date FOR Month: " + month + " " + "Year: " + year);
				Calendar calendar = Calendar.getInstance();
				setCurrentDayOfMonth(calendar.get(Calendar.DAY_OF_MONTH));
				setCurrentWeekDay(calendar.get(Calendar.DAY_OF_WEEK));
				Log.d(tag, "New Calendar:= " + calendar.getTime().toString());
				Log.d(tag, "CurrentDayOfWeek :" + getCurrentWeekDay());
				Log.d(tag, "CurrentDayOfMonth :" + getCurrentDayOfMonth());

				// Print Month
				printMonth(month, year);

				// Find Number of Events
				eventsPerMonthMap = findNumberOfEventsPerMonth(year, month);
			}
		private String getMonthAsString(int i)
			{
				return months[i];
			}

		private String getWeekDayAsString(int i)
			{
				return weekdays[i];
			}

		private int getNumberOfDaysOfMonth(int i)
			{
				switch (i) {
				case 0:
					if (year % 4 == 0) {
						return daysOfMonth[i] - 1;
					}
					return daysOfMonth[i];
				case 1:
					if (year % 4 == 0) {
						return daysOfMonth[i] + 1;
					}
					return daysOfMonth[i];
				default:
					return daysOfMonth[i];
				}
			}

		public String getItem(int position)
			{
				return list.get(position);
			}

		public int getCount()
			{
				return list.size();
			}

		/**
		 * Prints Month
		 * 
		 * @param mm
		 * @param yy
		 */
		private void printMonth(int mm, int yy)
			{
				Log.d(tag, "==> printMonth: mm: " + mm + " " + "yy: " + yy);
				// The number of days to leave blank at
				// the start of this month.
				int trailingSpaces = 0;
//				int leadSpaces = 0;
				int daysInPrevMonth = 0;
				int prevMonth = 0;
				int prevYear = 0;
				int nextMonth = 0;
				int nextYear = 0;

				int currentMonth = mm - 1;
				String currentMonthName = getMonthAsString(currentMonth);
				daysInMonth = getNumberOfDaysOfMonth(currentMonth);

				Log.d(tag, "Current Month: " + " " + currentMonthName + " having " + daysInMonth + " days.");

				// Gregorian Calendar : MINUS 1, set to FIRST OF MONTH
				GregorianCalendar cal = new GregorianCalendar(yy, currentMonth, 1);
				Log.d(tag, "Gregorian Calendar:= " + cal.getTime().toString());

				if (currentMonth == 11)
					{
						prevMonth = currentMonth - 1;
						daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
						nextMonth = 0;
						prevYear = yy;
						nextYear = yy + 1;
						Log.d(tag, "*->PrevYear: " + prevYear + " PrevMonth:" + prevMonth + " NextMonth: " + nextMonth + " NextYear: " + nextYear);
					}
				else if (currentMonth == 0)
					{
						prevMonth = 11;
						prevYear = yy - 1;
						nextYear = yy;
						daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
						nextMonth = 1;
						Log.d(tag, "**--> PrevYear: " + prevYear + " PrevMonth:" + prevMonth + " NextMonth: " + nextMonth + " NextYear: " + nextYear);
					}
				else
					{
						prevMonth = currentMonth - 1;
						nextMonth = currentMonth + 1;
						nextYear = yy;
						prevYear = yy;
						daysInPrevMonth = getNumberOfDaysOfMonth(prevMonth);
						Log.d(tag, "***---> PrevYear: " + prevYear + " PrevMonth:" + prevMonth + " NextMonth: " + nextMonth + " NextYear: " + nextYear);
					}

				// Compute how much to leave before before the first day of the
				// month.
				// getDay() returns 0 for Sunday.
				int currentWeekDay = cal.get(Calendar.DAY_OF_WEEK) - 1;
				trailingSpaces = currentWeekDay;

				Log.d(tag, "Week Day:" + currentWeekDay + " is " + getWeekDayAsString(currentWeekDay));
				Log.d(tag, "No. Trailing space to Add: " + trailingSpaces);
				Log.d(tag, "No. of Days in Previous Month: " + daysInPrevMonth);

				if (cal.isLeapYear(cal.get(Calendar.YEAR)) && mm == 1)
					{
						++daysInMonth;
					}

				// Trailing Month days
				for (int i = 0; i < trailingSpaces; i++)
					{
						Log.d(tag, "PREV MONTH:= " + prevMonth + " => " + getMonthAsString(prevMonth) + " " + String.valueOf((daysInPrevMonth - trailingSpaces + DAY_OFFSET) + i));
						list.add(String.valueOf((daysInPrevMonth - trailingSpaces + DAY_OFFSET) + i) + "-GREY" + "-" + getMonthAsString(prevMonth) + "-" + prevYear);
					}

				// get the days that contain events
				int[] intEventDays = getEventDays(daysInMonth);
				
				// Current Month Days
				for (int i = 1; i <= daysInMonth; i++)
					{
						Log.d(currentMonthName, String.valueOf(i) + " " + getMonthAsString(currentMonth) + " " + yy);
						if (intEventDays[i] == 1) {
							if (i == getCurrentDayOfMonth())
							{
								list.add(String.valueOf(i) + "*-BLUE" + "-" + getMonthAsString(currentMonth) + "-" + yy);
							}
							else
							{
								list.add(String.valueOf(i) + "*-WHITE" + "-" + getMonthAsString(currentMonth) + "-" + yy);
							}
						}
						else {
							if (i == getCurrentDayOfMonth())
							{
								list.add(String.valueOf(i) + "-BLUE" + "-" + getMonthAsString(currentMonth) + "-" + yy);
							}
							else
							{
								list.add(String.valueOf(i) + "-WHITE" + "-" + getMonthAsString(currentMonth) + "-" + yy);
							}							
						}
					}

				// Leading Month days
				for (int i = 0; i < list.size() % 7; i++)
					{
						Log.d(tag, "NEXT MONTH:= " + getMonthAsString(nextMonth));
						list.add(String.valueOf(i + 1) + "-GREY" + "-" + getMonthAsString(nextMonth) + "-" + nextYear);
					}
			}

		/**
		 * NOTE: YOU NEED TO IMPLEMENT THIS PART Given the YEAR, MONTH, retrieve
		 * ALL entries from a SQLite database for that month. Iterate over the
		 * List of All entries, and get the dateCreated, which is converted into
		 * day.
		 * 
		 * @param year
		 * @param month
		 * @return
		 */
		private HashMap<String, Integer> findNumberOfEventsPerMonth(int year, int month)
			{
				HashMap<String, Integer> map = new HashMap<String, Integer>();
				// DateFormat dateFormatter2 = new DateFormat();
				//						
				// String day = dateFormatter2.format("dd", dateCreated).toString();
				//
				// if (map.containsKey(day))
				// {
				// Integer val = (Integer) map.get(day) + 1;
				// map.put(day, val);
				// }
				// else
				// {
				// map.put(day, 1);
				// }
				return map;
			}

		public long getItemId(int position)
			{
				return position;
			}

		public View getView(int position, View convertView, ViewGroup parent)
			{
				View row = convertView;
				if (row == null)
					{
						LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
						row = inflater.inflate(R.layout.calendar_day_gridcell, parent, false);
					}

				// Get a reference to the Day gridcell
				gridcell = (Button) row.findViewById(R.id.calendar_day_gridcell);
				gridcell.setOnClickListener(this);

				// ACCOUNT FOR SPACING

				Log.d(tag, "Current Day: " + getCurrentDayOfMonth());
				String[] day_color = list.get(position).split("-");
				String theday = day_color[0];
				String themonth = day_color[2];
				String theyear = day_color[3];
				if ((!eventsPerMonthMap.isEmpty()) && (eventsPerMonthMap != null))
					{
						if (eventsPerMonthMap.containsKey(theday))
							{
								num_events_per_day = (TextView) row.findViewById(R.id.num_events_per_day);
								Integer numEvents = (Integer) eventsPerMonthMap.get(theday);
								num_events_per_day.setText(numEvents.toString());
							}
					}

				// Set the Day GridCell
				gridcell.setText(theday);
				gridcell.setTag(theday + "-" + themonth + "-" + theyear);
				Log.d(tag, "Setting GridCell " + theday + "-" + themonth + "-" + theyear);

				if (day_color[1].equals("GREY"))
					{
						gridcell.setTextColor(Color.LTGRAY);
					}
				if (day_color[1].equals("WHITE"))
					{
						gridcell.setTextColor(Color.WHITE);
					}
				if (day_color[1].equals("BLUE"))
					{
						gridcell.setTextColor(getResources().getColor(R.color.static_text_color));
					}
				return row;
			}
		public void onClick(View view)
			{
				String date_month_year = (String) view.getTag();
				if (date_month_year.contains("*-")) {
					date_month_year=date_month_year.substring(0,date_month_year.indexOf("*"))+date_month_year.substring(date_month_year.indexOf("*")+1,date_month_year.length());
				}

				selectedDayMonthYearButton.setText("Selected: " + date_month_year);

				try
					{
						Log.d("date_month_year = ", date_month_year);
						Date parsedDate = dateFormatter.parse(date_month_year);
						Bundle b = new Bundle();
						b.putSerializable("DATE", parsedDate);
						Log.d(tag,"Calling showDialog...");
						showDialog(DIALOG_EVENTS,b);
						//TODO:
						//Display a dialog with a list of events for that date, so the user can pick which one they want to view
						
						
						Log.d(tag, "Parsed Date: " + parsedDate.toString());

					}
				catch (ParseException e)
					{
						e.printStackTrace();
					}
			}

		public int getCurrentDayOfMonth()
			{
				return currentDayOfMonth;
			}

		private void setCurrentDayOfMonth(int currentDayOfMonth)
			{
				this.currentDayOfMonth = currentDayOfMonth;
			}
		public void setCurrentWeekDay(int currentWeekDay)
			{
				this.currentWeekDay = currentWeekDay;
			}
		public int getCurrentWeekDay()
			{
				return currentWeekDay;
			}
	}

	
}
